<?php
/*
 * 1626cms 職位相關函數
 * ============================================================================
 * 版權所有: 1626網絡，并保留所有權利。
 * 網站地址: http://www.1626.com；
 * ----------------------------------------------------------------------------
 * 這不是一個自由軟件！您只能在不用于商業目的的前提下對程序代碼進行修改和
 * 使用；不允許對程序代碼以任何形式任何目的的再發布。
 * ============================================================================
*/
if (! defined ( 'IN_QISHI' )) {
	die ( 'Access Denied!' );
}

function get_jobs_other_wage($job_id) {
	global $db;
	$sql = "select * from " . table ( 'jobs_welfare' ) . " where job_id=" . $job_id;
	$jobs_welfare_list = $db->getall ( $sql );
	return $jobs_welfare_list;
}
function get_jobs_shiftwork($job_id) {
	global $db;
	$sql = "select * from " . table ( 'jobs_shiftwork' ) . " where job_id=" . $job_id;
	$jobs_shiftwork_list = $db->getall ( $sql );
	return $jobs_shiftwork_list;
}
//讀取職位性質
function get_jobs_nature() {
	global $db;
	$sql = "select * from " . table ( 'jobs_nature' ) . "  ORDER BY category_order desc,id asc";
	$jobs_nature_list = $db->getall ( $sql );
	return $jobs_nature_list;
}
//根據ID獲取 職位性質(單個)
function get_jobs_nature_one($val) {
	global $db;
	if (intval ( $val ) != $val)
		return false;
	$sql = "select * from " . table ( 'jobs_nature' ) . " where id=" . $val;
	$category_one = $db->getone ( $sql );
	return $category_one;
}
//讀取薪資待遇劃分
function get_jobs_wage() {
	global $db;
	$sql = "select * from " . table ( 'jobs_wage' ) . "  ORDER BY category_order desc,id asc";
	$list = $db->getall ( $sql );
	return $list;
}
//根據ID獲取 薪資待遇(單個)
function get_jobs_wage_one($val) {
	global $db;
	if (intval ( $val ) != $val)
		return false;
	$sql = "select * from " . table ( 'jobs_wage' ) . " where id=" . $val;
	$category_one = $db->getone ( $sql );
	return $category_one;
}
//讀取時間段劃分
function get_jobs_settr() {
	global $db;
	$sql = "select * from " . table ( 'jobs_settr' ) . "  ORDER BY category_order desc,id asc";
	$list = $db->getall ( $sql );
	return $list;
}
//根據days獲取時間段劃分(單個)
function get_jobs_settr_one($val) {
	global $db;
	if (intval ( $val ) != $val)
		return false;
	$sql = "select * from " . table ( 'jobs_settr' ) . " where days=" . $val;
	$category_one = $db->getone ( $sql );
	return $category_one;
}
//讀取企業性質分類
function get_jobs_corporation() {
	global $db;
	$sql = "select * from " . table ( 'jobs_corporation' ) . "  ORDER BY category_order desc,id asc";
	$list = $db->getall ( $sql );
	return $list;
}
//讀取企業性質分類(單個)
function get_jobs_corporation_one($val) {
	global $db;
	if (intval ( $val ) != $val || $val == "")
		return false;
	$sql = "select * from " . table ( 'jobs_corporation' ) . " where id=" . $val;
	$category_one = $db->getone ( $sql );
	return $category_one;
}
//讀取行業劃分
function get_jobs_trade() {
	global $db;
	$sql = "select * from " . table ( 'jobs_trade' ) . "  ORDER BY category_order desc,id asc";
	$list = $db->getall ( $sql );
	return $list;
}
//根據ID獲取行業(單個)
function get_jobs_trade_one($val = 1) {
	global $db;
	if ($val == "")
		return false;
	$sql = "select * from " . table ( 'jobs_trade' ) . " where id=" . $val;
	$category_one = $db->getone ( $sql );
	return $category_one;
}
//讀取 地區 劃分列表
function get_jobs_area() {
//	global $db;
//	$sql = "select * from " . table ( 'jobs_area' ) . "  ORDER BY category_order desc,id asc";
//	$list = $db->getall ( $sql );
//	return $list;
		$a=array('101'=>'中區','102'=>'東區','103'=>'南區','104'=>'灣仔區','105'=>'西區');
		$b=array('201'=>'九龍城區','202'=>'觀塘區','203'=>'深水埗區','204'=>'黃大仙區','205'=>'油尖旺區');
		$c=array('301'=>'葵青區','302'=>'新界北區','303'=>'西貢區','304'=>'沙田區','305'=>'大埔區','306'=>'荃灣區','307'=>'屯門區','308'=>'元朗區');
		$d=array('401'=>'長洲區','402'=>'大嶼山區');
		
		$arr=array(
			array('100'=>'--全香港島--'),$a,
			array('200'=>'--全九龍--'),$b,
			array('300'=>'--全新界--'),$c,
			array('400'=>'--全離島--'),$d,
			array('500'=>'其他離島區'),
			array('600'=>'香港以外地區')
		);
		
		foreach($arr as $key => $value)
		{
			
			if(is_array($value)){
			foreach ($value as $k=> $area){
				$row['categoryname']=$area;			
				$row['id']=$k;
				$val[] = $row;
				}
			}
			else {
				$row['categoryname']=$value;			
				$row['id']=$key;
				$val[] = $row;
				
			}
			
		}
		return $val;
}
//根據ID獲取 地 區(單個)
function get_jobs_area_one($areakey = 101) {
//	global $db;
//	if ($val == "")
//		$val=1;
//	$sql = "select * from " . table ( 'jobs_area' ) . " where id=" . $val;
//	$category_one = $db->getone ( $sql );
//	return $category_one;
		
		
		$a=array('101'=>'中區','102'=>'東區','103'=>'南區','104'=>'灣仔區','105'=>'西區');
		$b=array('201'=>'九龍城區','202'=>'觀塘區','203'=>'深水埗區','204'=>'黃大仙區','205'=>'油尖旺區');
		$c=array('301'=>'葵青區','302'=>'新界北區','303'=>'西貢區','304'=>'沙田區','305'=>'大埔區','306'=>'荃灣區','307'=>'屯門區','308'=>'元朗區');
		$d=array('401'=>'長洲區','402'=>'大嶼山區');
		$e=array('100'=>'--全香港島--','200'=>'--全九龍--','300'=>'--全新界--','400'=>'--全離島--','500'=>'其他離島區','600'=>'香港以外地區');
		$arealist=$a+$b+$c+$d+$e;
		foreach($arealist as $key => $value)
		{
		
			$row[$key]['categoryname']=$value;			
			$row[$key]['id']=$key;
			$val[$key] = $row[$key];		
		}		
		return $val[$areakey];	
}
//獲取專業資格途徑
function get_wayofeducation($id='')
{
//	$ways=array('0'=>array('id'=>'1','title'=>'考試'),'1'=>array('id'=>'2','title'=>'推選'),'2'=>array('id'=>'3','title'=>'未知'),'3'=>array('id'=>'4','title'=>'保密'),'4'=>array('id'=>'5','title'=>'世襲'),'5'=>array('id'=>'6','title'=>'天上掉下來'));
	$ways=array('1'=>'考試','2'=>'推選','3'=>'未知','4'=>'保密','5'=>'世襲','6'=>'天上掉下來');
	if($id)return $ways[$id];
	else return $ways;
}
//讀取 學歷 劃分
function get_jobs_education() {
	global $db;
	$sql = "select * from " . table ( 'jobs_education' ) . "  ORDER BY category_order desc,id asc";
	$list = $db->getall ( $sql );
	return $list;
}
//根據ID 獲取 學歷(單個)
function get_jobs_education_one($val = 1) {
	global $db;
	$sql = "select * from " . table ( 'jobs_education' ) . " where id=" . $val;
	$category_one = $db->getone ( $sql );
	return $category_one;
}
//讀取 工作經驗 劃分
function get_jobs_experience() {
	global $db;
	$sql = "select * from " . table ( 'jobs_experience' ) . "  ORDER BY category_order desc,id asc";
	$list = $db->getall ( $sql );
	return $list;
}
//根據ID 獲取 工作經驗(單個)
function get_jobs_experience_one($val = 1) {
	global $db;
	if ($val == "")
		return false;
	$sql = "select * from " . table ( 'jobs_experience' ) . " where id=" . $val;
	$category_one = $db->getone ( $sql );
	return $category_one;
}
//讀取 公司規模 劃分
function get_jobs_scale() {
	global $db;
	$sql = "select * from " . table ( 'jobs_scale' ) . "  ORDER BY category_order desc,id asc";
	$list = $db->getall ( $sql );
	return $list;
}
//根據ID 獲取 公司規模(單個)
function get_jobs_scale_one($val = 1) {
	global $db;
	if ($val == "")
		return false;
	$sql = "select * from " . table ( 'jobs_scale' ) . " where id=" . $val;
	$category_one = $db->getone ( $sql );
	return $category_one;
}
//獲取職能職位分類(所有)------------------------
function get_jobs_category($len = 10, $len1 = 8) {
	global $db;
	$result = $db->query ( "SELECT * FROM " . table ( 'jobs_category' ) . " where ParentID='0' ORDER BY category_order desc,id asc" );
	while ( $row = $db->fetch_array ( $result ) ) {
		$row ['categoryname_1'] = cut_str ( $row ['categoryname'], $len, 0 );
		$row ['categoryname_2'] = cut_str ( $row ['categoryname'], $len1, 0 );
		$category_list [] = $row;
	}
	return $category_list;
}
//根據ID獲取職能分類(單個)
function get_jobs_category_one($val = 1) {
	global $db;
	if ($val == "")
		return false;
	$sql = "select * from " . table ( 'jobs_category' ) . " where id=" . $val;
	$category_one = $db->getone ( $sql );
	return $category_one;
}
//獲取職位頂級分類
function get_jobs_Parent() {
	global $db;
	$sql = "select * from " . table ( 'jobs_category' ) . " where ParentID=0  ORDER BY category_order desc,id asc";
	$category_list = $db->getall ( $sql );
	return $category_list;
}
//獲取目標父級分類下的小類
function get_jobs_Parent_list($val = 0) {
	global $db;
	$result = $db->query ( "select * from " . table ( 'jobs_category' ) . " where ParentID=" . $val . "  ORDER BY category_order desc,id asc" );
	while ( $row = $db->fetch_array ( $result ) ) {
		$row ['categoryname_1'] = cut_str ( $row ['categoryname'], 9, 0 );
		$category_list [] = $row;
	}
	return $category_list;
}
?>
